// 计算服务器处理时常

module.exports = async (ctx, next) => {
  const start = Date.now()
  // 放行内层中间件执行
  await next()

  // 响应时间
  const end = Date.now()
  const duration = end - start
  // 设置响应头ms
  ctx.set('x-response-Time', duration + 'ms')
}
